<?php
namespace app\common\business;

use app\common\model\mysql\Demo as DemoModel;
class Demo
{

    /**
     * business层通过getDemoDataByCategoryId来获取数据
     * @param $categoryId
     * @param $limit
     * @return array|mixed
     */
    public function getDemoDataByCategoryId($categoryId, $limit = 10)
    {
        $model = new DemoModel();
        $results = $model->getDemoDataByCategoryId($categoryId,$limit);
        if(empty($results)){
            return [];
        }
        $categorys = config("category");
        foreach ($results as $k => $v)
        {
            $results[$k]['categoryName'] = $categorys[$v["category_id"]] ?? "其他";
        }

        return $categorys;
    }
}